/************************************************************
* @file gkt_core.h
************************************************************/

#ifndef GKT_CORE_H
#define GKT_CORE_H

#include "gkt_config.h"

/* System irq(exception) numbers */
#define GKT_SYSIRQ_NUMS	16

/* priority of Configurable IRQ */
#define GKT_IRQ_PRIORITY_INVALID	(1 << __NVIC_PRIO_BITS)
#define GKT_IRQ_PRIORITY_KERNEL	(GKT_IRQ_PRIORITY_INVALID - 1)	/* 3 - 0xE0 -- SysTick, PendSV, ... */
#define GKT_IRQ_PRIORITY_LOW	(GKT_IRQ_PRIORITY_KERNEL - 1)	/* 2 - 0x80 -- Device IRQ */
#define GKT_IRQ_PRIORITY_NORMAL	(GKT_IRQ_PRIORITY_LOW - 1)		/* 1 - 0x40 -- Device IRQ */
#define GKT_IRQ_PRIORITY_HIGH	(GKT_IRQ_PRIORITY_NORMAL - 1)	/* 0 - 0x00 -- Device IRQ */
#define GKT_IRQ_PRIORITY_REAL	GKT_IRQ_PRIORITY_HIGH
#define GKT_IRQ_PRIORITY_SYSCALL	GKT_IRQ_PRIORITY_HIGH
#define GKT_IRQ_PRIORITY_MASK	(((1 << __NVIC_PRIO_BITS) - 1) << (8U - __NVIC_PRIO_BITS))

#define GKT_IRQ_PRIORITY_FROM_REGVAL(reg_value)	\
	(((reg_value) & GKT_IRQ_PRIORITY_MASK) >> (8U - __NVIC_PRIO_BITS))
#define GKT_IRQ_PRIORITY_TO_REGVAL(priority)	\
	((priority) << (8U - __NVIC_PRIO_BITS))

#include "gkt_core_irq.h"

#define GKT_SYSINC_HAS_RBIT	0

void gkt_core_init(void);

#include "gkt_systime.h"

#endif	/* GKT_CORE_DEFINES_H */

